package com.ruoyi.job.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.business.waterManagement.WrStatvolD;
import com.ruoyi.common.core.domain.business.waterManagement.WrStatvolM;
import com.ruoyi.common.core.domain.business.waterManagement.WrStatvolY;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.job.mapper.WrStatvolDMapper;
import com.ruoyi.job.mapper.WrStatvolYMapper;
import com.ruoyi.job.service.IWrStatvolDService;
import com.ruoyi.job.service.IWrStatvolYService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 测站年水量数据Service业务层处理
 * 
 * @author hwd
 * @date 2023-02-20
 */
@Service
public class WrStatvolYServiceImpl extends ServiceImpl<WrStatvolYMapper, WrStatvolY> implements IWrStatvolYService
{
    @Autowired
    private WrStatvolYMapper wrStatvolYMapper;

    /**
     * 查询测站年水量数据
     * 
     * @param statCd 测站年水量数据主键
     * @return 测站年水量数据
     */
    @Override
    public WrStatvolY selectWrStatvolYByStatCd(String statCd)
    {
        return wrStatvolYMapper.selectWrStatvolYByStatCd(statCd);
    }

    /**
     * 查询测站年水量数据列表
     * 
     * @param wrStatvolY 测站年水量数据
     * @return 测站年水量数据
     */
    @Override
    public List<WrStatvolY> selectWrStatvolYList(WrStatvolY wrStatvolY)
    {
        return wrStatvolYMapper.selectWrStatvolYList(wrStatvolY);
    }

    /**
     * 新增测站年水量数据
     * 
     * @param wrStatvolY 测站年水量数据
     * @return 结果
     */
    @Override
    public int insertWrStatvolY(WrStatvolY wrStatvolY)
    {
        return wrStatvolYMapper.insertWrStatvolY(wrStatvolY);
    }

    /**
     * 修改测站年水量数据
     * 
     * @param wrStatvolY 测站年水量数据
     * @return 结果
     */
    @Override
    public int updateWrStatvolY(WrStatvolY wrStatvolY)
    {
        return wrStatvolYMapper.updateWrStatvolY(wrStatvolY);
    }

    /**
     * 批量删除测站年水量数据
     * 
     * @param statCds 需要删除的测站年水量数据主键
     * @return 结果
     */
    @Override
    public int deleteWrStatvolYByStatCds(String[] statCds)
    {
        return wrStatvolYMapper.deleteWrStatvolYByStatCds(statCds);
    }

    /**
     * 删除测站年水量数据信息
     * 
     * @param statCd 测站年水量数据主键
     * @return 结果
     */
    @Override
    public int deleteWrStatvolYByStatCd(String statCd)
    {
        return wrStatvolYMapper.deleteWrStatvolYByStatCd(statCd);
    }

    @Override
    public void insertOrUpdateWrStatvolY(WrStatvolM wrStatvolM, Date year) {
        String [] strings= DateUtils.jsYmd(year);
        String yy =strings[0];
        WrStatvolY saveWrStatvolY =new WrStatvolY();
        saveWrStatvolY.setStatCd(wrStatvolM.getStatCd());
        saveWrStatvolY.setYrLevel(wrStatvolM.getMonLevel());
        saveWrStatvolY.setYrFlow(wrStatvolM.getMonFlow());
        saveWrStatvolY.setYrVol(wrStatvolM.getMonVol());
        saveWrStatvolY.setStatYr(yy);
        wrStatvolYMapper.insertOrUpdateWrStatvolY(saveWrStatvolY);
    }

    @Override
    public WrStatvolY countWiOrgVolYByWrStatvolY(String statCd, Date day) {
        String [] strings= DateUtils.jsYmd(day);
        String yy =strings[0];
        return wrStatvolYMapper.countWiOrgVolYByWrStatvolY(statCd,yy);
    }


}
